<?php
function ui_print_header($title)
{
	$title=htmlentities($title);
	$active=array('index'=>'','projects'=>'','control'=>'','forums'=>'','login'=>'','register'=>'');
	$active[$title]='active';
	echo <<<END
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
	<html>
	<head>
	<meta http-equiv="Content-Type"
	content="text/html; charset=ISO-8859-1">
	<link rel="stylesheet" type="text/css" href="style.css">
	<title>COP5725 Co.: $title</title>
	</head>
		<div id="menu">
<ul>
END;
	echo    '<li><a class="'.$active['index'].'" href="index.php">Home</a></li>';
	echo    '<li><a class="'.$active['projects'].'" href="projects.php">projects</a></li>';
	echo    '<li><a class="'.$active['control'].'" href="control.php">control</a></li>';
	echo    '<li><a class="'.$active['forums'].'" href="forums.php">forums</a></li>';
	echo    '<li><a class="'.$active['login'].'" href="login.php">login</a></li>';
	echo    '<li><a class="'.$active['register'].'" href="register.php">register</a></li>';
	echo <<<END
</ul>

</div>
	<body>
	<div id="pagebody">
<div id="mainbody">
END;
}



function ui_print_login_form($posturl)
{
	echo<<<END
	<form method="post" action="$posturl" >
<table>
	<tr>
		<td>Username</td>
		<td><input type="text" name="uname" size="20"></td>
	</tr>
	<tr>
		<td>password</td>
		<td><input type="password" name="password" size="20"></td>
	</tr>
	<tr>
</table>
<input type="submit" value="Login NOW" name="login">
</form>
END;
}
function ui_print_register_form($posturl)
{
	/* USERS has Uname password which are requried
	 * EMail
	 * city
	 * state
	 * country
	 * and a long description
	 * */
	echo<<<END
	<form method="post" action="$posturl" >
<table>
	<tr>
		<td>Username</td>
		<td><input type="text" name="uname" size="20"></td>
	</tr>
	<tr>
		<td>password</td>
		<td><input type="password" name="password" size="20"></td>
	</tr>
	<tr>
		<td>email</td>
		<td><input type="text" name="email" size="20"></td>
	</tr>
	<tr>
		<td>city</td>
		<td><input type="text" name="city" size="20"></td>
	</tr>
	<tr>
		<td>state</td>
		<td><input type="text" name="state" size="20"></td>
	</tr>
	<tr>
		<td>country</td>
		<td><input type="text" name="country" size="20"></td>
	</tr>
	
</table>	
	<input type="submit" value="Register NOW" name="register">
	<input type="submit" value="Cancel" name="cancel">
END;
}

/*
 * specilify output controls
 * */
function ui_print_projects($prjcts,$posturl)
{
	if(!$prjcts ){
		echo '<p>No Projects found</p>';
	}
	else{
		echo <<<END
		<form method="post" action="$posturl">
<table>
	<tr>
		<th></th>
		<th>Projectn Title</th>
		<th>Posted Time</th>
		<th>Posted By</th>
		<th>Description</th>
	</tr>
	
END;
		//var_dump($prjcts);
		foreach($prjcts as $prjct)
		{	echo '<tr>';
		echo '<td><input type="radio" name="selectpid"
	value="'.htmlentities($prjct['PID']).'"></td>';
		echo '<td>'.htmlentities($prjct['TITLE']).'</td>';
		echo '<td>'.htmlentities($prjct['POSTTIME']).'</td>';
		echo '<td>'.htmlentities($prjct['UNAME']).'</td>';
		echo '<td>'.htmlentities($prjct['DESCRIPTION']).'</td>';
		echo '</tr>';
		}
		echo <<<END
</table>
<input type="submit" value="First" name="firstpage">
<input type="submit" value="< Previous" name="prevpage">
<input type="submit" value="Next >" name="nextpage">
<input type="submit" value="Show Project" name="showdetails">	
</form>
END;
	}
}

function ui_print_newproject_form($posturl)
{
	echo <<<END
	<form method="post" action="$posturl" enctype="multipart/form-data">
	<table>
	<tr>
		<td>Project Title</td>
		<td><input type="text" name="title" value="" size="100"></td>
	</tr>
	<tr>
		<td>Project Description</td>
		<td><textarea name="description" cols="80" rows="20" value="" size="4000"></textarea></td>
	</tr>
	</table>
	<input type="file" name="pic1"><br>
	<input type="file" name="pic2"><br>
	<input type="file" name="pic3"><br>
	<input type="submit" name="postprject" value="Post Project" >
	</form>
END;
}

function ui_print_project_details($arr)
{
if($arr){
	$pid=htmlentities($arr['PID']);
	$title=htmlentities($arr['TITLE']);
	$posttime=htmlentities($arr['POSTTIME']);
	$uname=htmlentities($arr['UNAME']);
//	$pic1=$arr['PIC1'];
//	$pic2=$arr['PIC2'];
//	$pic3=$arr['PIC3'];
	$pic1=$arr['PIC1']->load();
	$pic2=$arr['PIC2']->load();
	$pic3=$arr['PIC3']->load();
	$description=htmlentities($arr['DESCRIPTION']);
/*echo <<<END
<table>
	<tr>
		<td>Project ID</td>
		<td>$pid</td>
	</tr>
	<tr>
		<td>TITLE</td>
		<td>$title</td>
	</tr>
	<tr>
		<td>Description</td>
		<td>$description</td>
	</tr>
	<tr>
		<td>Posted By</td>
		<td>at</td>
	</tr>
	<tr>
		<td>$uname</td>
		<td>$posttime</td>
	</tr>
END;
echo	'<tr><td>';*/
header("Content-type: image/JPEG");
echo $pic2;
/*echo	'</td></tr>';		
echo 	'</table>';	
*/
}
else{
	echo 'no such a projects';
}
}

function ui_print_footer($date)
{
	$date=htmlentities($date);
	echo <<<END
	</div>
	</div>
	<div class="footer">
	<div class="date">$date</div>
</div>
END;
}
?>